package eraserhead.controller;

import eraserhead.boundary.ChoicePanel;
import eraserhead.entity.Decision;

/**
 * Controller for users.
 * @author Cian
 * @author Greg
 * @author Quanquan
 */
public class UserController {
	
	Decision model;
	ChoicePanel view;

	/**
	 * Creates a new {@link UserController}
	 * @param model {@link Decision} to control
	 * @param view {@link ChoicePanel} associated with the model
	 */
	public UserController(Decision model, ChoicePanel view) {
	 	this.model = model;
	 	this.view = view;	 	
	}

	public void process() {
		if (view.getCanGiveChoice()) {
			boolean[] canEdit = model.userGiveChoice();
			for (int i = 0; i < model.getNumUsers(); i++) {
				view.getChoiceField(i).setEditable(canEdit[i]);
			}
		} else {
			for (int i = 0; i < model.getNumUsers(); i++) {
				view.getChoiceField(i).setEditable(false);
			}
		}
	}
}
